package top.yuhaitao.cloud.filter;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

public class PreZuulFilter extends ZuulFilter {
	private final static Logger log = LoggerFactory.getLogger(PreZuulFilter.class);

	@Override
	public Object run() {
		// 具体逻辑
		HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
		String remoteHost = request.getRemoteHost();
		log.info("remoteHost:remoteHost:remoteHost:remoteHost:" + remoteHost);
		return null;
	}

	@Override
	public boolean shouldFilter() {
		// 是否开启
		return true;
	}

	@Override
	public int filterOrder() {
		//执行顺序 越大越靠后
		return 0;
	}

	@Override
	public String filterType() {
		// filter 类型
		return "pre";
	}

}
